package service

import (
	"github.com/gin-gonic/gin"
	"likeadmin/admin/schemas/req"
	"likeadmin/admin/schemas/resp"
	"likeadmin/dao"
)

type IUserService interface {
	List(c *gin.Context, req *req.SystemLoginReq) (res resp.SystemLoginResp, e error)
}

// NewUserService 初始化
func NewUserService(dao *dao.Query) IUserService {
	return &userService{dao: dao}
}

// userService 系统管理员服务实现类
type userService struct {
	dao *dao.Query
}

func (userSrv userService) List(c *gin.Context, req *req.SystemLoginReq) (res resp.SystemLoginResp, e error) {
	u := userSrv.dao.User.WithContext(c)
	user, err := u.First()
	println(user.RealName, err)
	return resp.SystemLoginResp{Token: user.Nickname}, nil
}
